#include "wdt.h"
#include "uart0.h"
#include "iic.h"

extern void printf(const char *fmt, ...);

void delay_ms(unsigned int ms)
{
	unsigned int i,j;
	for(i = 0; i < ms; i++)
		for(j = 0; j < 1800; j++);
}


int main()
{
	// 调用硬件初始化的函数
    hal_uart0_init();
    mma8451_init();
    short x;
    short y;
    short z;

	while(1)
	{
        x = get_xyz_from_mma8451(0x1);
        y = get_xyz_from_mma8451(0x3);
        z = get_xyz_from_mma8451(0x5);

        x = x * 2 * 9800 / 8192;
        y = y * 2 * 9800 / 8192;
        z = z * 2 * 9800 / 8192;
        printf("x:%d.%d y:%d.%d z:%d.%d\n", x/1000, x%1000,  y/1000, y%1000, z/1000, z%1000);
        delay_ms(500);
	}
	return 0;
}
